<?php
$latitude = isset($_GET['lat'])?$_GET['lat']:null;
if($latitude==null)return;
$longitude = isset($_GET['lng'])?$_GET['lng']:null;
if($longitude==null)return;
$offset = isset($_GET['off'])?$_GET['off']:null;
if($offset==null)return;
$fkey = 1;
include_once 'constants.php';
$mysqli = new mysqli($hostname,$username,$password,$database);/*
$sqlCheck = 'SELECT insertTs FROM loc_location where fk_pkey_loc_cust = 1' 
	.' insertTs > (NOW() + INTERVAL -5 minute) '
	.' order by insertTs limit 1';
$stmt = $mysqli->prepare($sqlCheck);
$rslt = $stmt->execute();
*/
$sql = 'insert into loc_location(fk_pkey_loc_unit,latitude,longitude,insertTs) values(?,?,?,NOW() + INTERVAL ? hour)';
$stmt = $mysqli->prepare($sql);
$stmt->bind_param('iddi',$fkey,$latitude,$longitude,$offset);
$stmt->execute();
$count = $stmt->affected_rows;
if($count!=1)header('HTTP/1.0 999 database error');
?>